#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    vector<int> occurrencesOfElement(vector<int>& nums, vector<int>& queries, int x) {
        vector<int> pos;
        int n = nums.size();
        for (int i = 0; i < n; i++)
        {
            if (nums[i] == x) pos.push_back(i);
        }
        vector<int> res;
        for (auto e : queries)
        {
            if (e > pos.size()) res.push_back(-1);
            else res.push_back(pos[e - 1]);
        }
        return res;
    }
};